﻿#include "targetplottingbutton.h"
extern void setButtonStyle(QPushButton *pushButton, const QString &imageUrl1, const QString &imageUrl2);
extern int leftDockBabyred,leftDockBabygreen,leftDockBabyblue;
extern float leftDockBabytransparency;
TargetPlottingButton::TargetPlottingButton(QWidget *parent) :
    QPushButton(parent)
{
    plottingWidget = new QWidget(parent);
    plottingWidget->setStyleSheet(QString("background-color:rgba(%1,%2,%3,%4);").arg(leftDockBabyred).arg(leftDockBabygreen).arg(leftDockBabyblue).arg(leftDockBabytransparency));
    plottingWidget->setFixedSize(500,500);
    plottingWidget->move(140,0);

    triangleWidget = new TriangleWidget(plottingWidget);
    triangleWidget->setFixedSize(100,100);
    triangleWidget->move(0,0);
    triangleWidget->setVisible(true);

    enemyButton = new QPushButton("enemy",plottingWidget);
    friendButton = new QPushButton("friend",plottingWidget);


    enemyButton->setFixedSize(129,50);
    friendButton->setFixedSize(129,50);
    friendButton->move(130,0);

    enemyWidget = new QWidget;
    friendWidget = new QWidget;
    enemyWidget->setFixedSize(500,450);
    friendWidget->setFixedSize(500,450);
    enemyWidget->move(0,50);
    friendWidget->move(0,50);

    QSize size=QSize(100,100);
    friendUAVbtn = new QPushButton(friendWidget);
    enemyPlanebtn = new QPushButton(enemyWidget);
    enemyTankbtn = new QPushButton(enemyWidget);
    enemyBunkerbtn = new QPushButton(enemyWidget);
    friendUAVbtn->setFixedSize(size);
    setButtonStyle(friendUAVbtn,":/image/wurenji.svg",":/image/wurenjiyixuan.svg");
    setButtonStyle(enemyPlanebtn,":/image/attack_plane.svg",":/image/attack_plane2.svg");
    setButtonStyle(enemyTankbtn,":/image/tank.svg",":/image/tank2.svg");
    setButtonStyle(enemyBunkerbtn,":/image/bunker.png",":/image/bunker2.png");
    enemyPlanebtn->setFixedSize(size);
    enemyTankbtn->setFixedSize(size);
    enemyBunkerbtn->setFixedSize(size);
    friendUAVbtn->move(80,30);
    enemyPlanebtn->move(80,30);
    enemyTankbtn->move(80,150);
    enemyBunkerbtn->move(80,270);


    isShow1=false;
    isShow2=false;
    connect(enemyButton,&QPushButton::clicked,[=](){
        if(isShow1==false){
            enemyWidget->setParent(plottingWidget);
            enemyWidget->show();
            friendWidget->hide();
            isShow1=true;
            isShow2=false;
        }
        else{
            enemyWidget->hide();
            isShow1=false;
        }
    });
    connect(friendButton,&QPushButton::clicked,[=](){
        if(isShow2==false){
            friendWidget->setParent(plottingWidget);
            friendWidget->show();
            enemyWidget->hide();
            isShow2=true;
            isShow1=false;
        }
        else{
            friendWidget->hide();
            isShow2=false;
        }
    });

}
